package main

import (
	"github.com/hyperledger/fabric/core/chaincode/shim"
	pb "github.com/hyperledger/fabric/protos/peer"
	"fmt"
)

type BaseChaincode struct {
}

func (t *BaseChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
	return shim.Success([]byte("init success"))
}

func (t *BaseChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
	function,_ := stub.GetFunctionAndParameters()
	if function == "add" {
		stub.PutState("a", []byte("aValue"))
		return shim.Success([]byte("add success"))
	} else if function == "query" {
		result, _ := stub.GetState("a")
		return shim.Success(result)
	} else {
		return shim.Success([]byte("no matching function"))
	}
}
func main() {
	err := shim.Start(new(BaseChaincode))
	if err != nil {
		fmt.Printf("Error starting the blacklist chaincode: %s", err)
	}
}
